#include "irc_parser.h"

irc_parser::irc_parser(void) : total_processed_lines( 0 )
{
}


irc_parser::~irc_parser(void)
{
}

irc_line *irc_parser::parse( const char *raw )
{
	if( raw == 0 )
		return 0;

	irc_line *ret = new irc_line();

	boost::regex ex( "^:(.*)!(.*)@(.*) PRIVMSG (.*) :(.*)" );
	boost::cmatch parts;

	if( boost::regex_match( raw, parts, ex ) )
	{
		std::string temp( parts[1].first, parts[1].second );
		ret->getParams()["nick"] = temp;

		std::string temp1( parts[2].first, parts[2].second );
		ret->getParams()["user"] = temp1;

		std::string temp2( parts[3].first, parts[3].second );
		ret->getParams()["host"] = temp2;

		std::string temp3( parts[4].first, parts[4].second );
		ret->getParams()["to"] = temp3;

		std::string temp4( parts[5].first, parts[5].second );
		ret->getParams()["message"] = temp4;
	}

	return ret;
}
